<template>
  <div class="dashboardContainer flex flex-column">
    <div class="dashboardContainer__header" v-if="$scopedSlots.header">
      <slot name="header" />
    </div>
    <div
      v-if="title || $scopedSlots.extra || extraTitle"
      :class="
        type
          ? 'dashboardContainer__header dashboardContainer__bottom'
          : 'dashboardContainer__header'
      "
      :style="{ ...headerStyle }"
    >
      <div v-if="icon" class="icon">
        <i v-if="!isSvgIcon" :class="icon"></i>
        <svg-icon v-else :icon="`svg-${icon}`" />
      </div>
      <div v-if="rectangularIcon" class="rectangularIcon"></div>
      <div class="flex-1">
        {{ title }}
      </div>
      <slot name="extra" />
      <span v-if="!$scopedSlots.extra" class="titleExtra">{{
        extraTitle
      }}</span>
    </div>
    <div
      class="dashboardContainer__body flex flex-column"
      :style="{ ...bodyStyle }"
    >
      <slot name="body-extra" />
      <div
        v-loading="loading"
        :class="auto ? 'flex-2' : 'flex-1'"
        style="position: relative"
      >
        <template v-if="$scopedSlots.default == null">
          <el-empty :style="emptyStyle" class="small-empty empty"></el-empty>
        </template>
        <template v-else>
          <slot />
        </template>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  components: {},
  props: {
    title: {
      type: String,
      default: ''
    },
    bodyStyle: {
      type: Object,
      default: () => {}
    },
    headerStyle: {
      type: Object,
      default: () => {}
    },
    icon: {
      type: String,
      default: undefined
    },
    rectangularIcon: {
      type: Boolean,
      default: false
    },
    isSvgIcon: {
      type: Boolean
    },
    extraTitle: {
      type: String,
      default: undefined
    },
    loading: {
      type: Boolean,
      default: false
    },
    emptyStyle: {
      type: [String, Object],
      default: undefined
    },
    auto: {
      type: Boolean,
      default: false
    },
    type: {
      type: String,
      default: null
    }
  },
  name: 'DashboardContainer',
  data () {
    return {};
  },
  created () {},
  mounted () {},
  methods: {},
  computed: {},
  watch: {}
};
</script>
<style lang='scss' scoped>
.dashboardContainer {
  overflow: hidden;
  background: #ffffff;
  // border-radius: 24px;
  &:not(:last-child) {
    margin-bottom: 19px;
  }
  &__header {
    position: relative;
    // padding: 38px 16px 12px 36px;
    padding: 16px 26px 16px 26px;
    font-size: 18px;
    display: flex;
    align-items: center;
    line-height: 1;
    height: auto;
    color: #0e8b8d;
    // font-size: 24px;
    font-weight: 500;
    text-align: left;
    .icon {
      width: 22px;
      height: 22px;
      margin-right: 5px;
    }
  }
  &__bottom {
    border-bottom: 1px solid;
    padding: 10px !important;
    font-size: 14px;
  }
  &__body {
    flex: 1;
    overflow: hidden;
    padding: 0 25px 22px;
  }
  .titleExtra {
    color: rgba(127, 127, 127);
    font-size: 12px;
  }
  ::v-deep .el-scrollbar__wrap {
    overflow-x: hidden;
    margin-bottom: 0px !important;
  }
  .rectangularIcon {
    border-width: 0px;
    width: 8px;
    height: 25px;
    background: inherit;
    background-color: rgba(14, 139, 141, 1);
    border: none;
    border-radius: 150px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    margin-right: 10px;
  }
}
</style>
